//
//  HBVideoFirstFrameViewController.m
//  HBLibary_Example
//
//  Created by Rambo on 2019/1/12.
//  Copyright © 2019 Rambo. All rights reserved.
//

#import "HBVideoFirstFrameViewController.h"
#import "UIImageView+videoFirstFrame.h"

@interface HBVideoFirstFrameViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, copy) NSArray *list;

@end

@implementation HBVideoFirstFrameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"视频第一张图片";

    
    self.list = @[@"http://112.253.22.162/15/r/q/v/j/rqvjngujuhggwagymdkgmcxgrtljxy/hc.yinyuetai.com/818501682B31097074314D5C5E0D7A24.mp4",
                  @"http://112.253.22.166/1/m/y/m/l/mymlouwbpascxvvqytsurdddfvctdb/hc.yinyuetai.com/ED0C016835914971D17789F576E51D8C.mp4",
                  @"http://112.253.22.163/13/k/k/j/l/kkjlekwkwkvxbobodlfwglvlnvwtub/hc.yinyuetai.com/8E2F01680C78A7CCD3B1B6386FCCD740.mp4",
                  @"http://112.253.22.166/5/h/l/g/s/hlgsfozhkuwzlgxikqsrqekasdsqwd/hc.yinyuetai.com/3E6D01680C700BF513FEA6C8D048588B.mp4",
                  @"http://112.253.22.166/8/h/y/q/h/hyqhsbubvwxjbhekeyokkziwizcdje/hc.yinyuetai.com/116C01682B8B5ED43DFFE49848CB644D.mp4",
                  @"http://112.253.22.166/8/c/a/u/v/cauvmnghkglbaelbthqidfrsbloavg/hc.yinyuetai.com/78FB01681742E0BC963D6F34C2D4B776.mp4",
                  @"http://112.253.22.166/8/x/l/x/k/xlxkzuhbpyrhhsnnsnwpkrsfzpufto/hc.yinyuetai.com/D62501683AC4EC4680F3C65A29E413A9.mp4",
                  @"http://112.253.22.160/2/a/d/k/f/adkfqsblxjyisgadbhmchltsksfuzc/hc.yinyuetai.com/D769016416819DE50B53DC4CC754243A.mp4"];
    
 
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView = ({
        UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        tableView.separatorColor = [UIColor clearColor];
        tableView.backgroundColor = self.view.backgroundColor;
        tableView.dataSource = self;
        tableView.delegate = self;
        
        tableView.rowHeight = 100;
        [self.view addSubview:tableView];
        tableView;
    });
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"cellId";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
        cell.textLabel.numberOfLines = 0;
        cell.textLabel.adjustsFontSizeToFitWidth = YES;
    }
    NSString *url = self.list[indexPath.row%self.list.count];
    
    cell.textLabel.textColor = [UIColor colorWithRed:arc4random()%255/255.f green:arc4random()%255/255.f blue:arc4random()%255/255.f alpha:1];
    cell.textLabel.text = url;
    [cell.imageView hb_setVideoFirstFrameWithUrl:url placeholderImage:nil];
    return cell;
}

- (void)dealloc{
    NSLog(@"%s",__func__);
}


@end
